//package com.itany.shop.filter;
//
//import com.itany.shop.entity.User;
//
//import javax.servlet.*;
//import javax.servlet.annotation.WebFilter;
//import javax.servlet.http.HttpServletRequest;;
//import java.io.IOException;
///**
// * @author 黄衡熙
// * @version 1.0
// * 用户在访问主页，登录,注册等相关功能时不需要验证其他功能必须验证
// */
//
//@WebFilter(urlPatterns="/*")
//public class logFilter2 implements Filter {
//    @Override
//    public void init(FilterConfig filterConfig) throws ServletException {
//        System.out.println("***********过滤的初始化方法***********");
//    }
//
//    @Override
////    参数三做放行操作的
//    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//        System.out.println("**************过滤的核心业务逻辑**************");
//        HttpServletRequest request= (HttpServletRequest) servletRequest;
//        String uri=request.getRequestURI();
//        System.out.println(uri);
//        if(uri.equals("/shop/jsp/login.jsp")||uri.equals("/shop/jsp/main.jsp")||uri.equals("/shop/jsp/register.jsp")){
//            filterChain.doFilter(servletRequest, servletResponse);
//            return;
//        }
//            User user = (User) request.getSession().getAttribute("user");
//            if(user !=null){
//                filterChain.doFilter(servletRequest, servletResponse);
//            }else{
//                request.getRequestDispatcher("/jsp/login.jsp").forward(request,servletResponse);
//            }
//        }
//
//    @Override
//    public void destroy() {
//        System.out.println("*******************过滤器的销毁方法*******************");
//    }
//}
